module Visualizer::VisualisationTreeADTGenerator

import Visualizer::VisualisationTreeADT;

import Integer;
import List;

/* 	This class contains methods to generate VisualisationTreeADT trees
	use the generateRootVisualisationTree() to get a full random tree.
	
	It is for testing and example purposes only.
*/


loc DEFAULT_LOC = |file:///somewhere/in.time|(0,1,<2,3>,<4,5>);

public VisualisationTree generateRootVisualisationTree(){
	return package("com" , [package("amce" , [package("miepmiep", generateVisualisationTreeList(), [])], []),package("amce2" , [package("miepmiep", generateVisualisationTreeList(), [])], [])], []);
}
public Method generateMethod(str className){
	return method(generateMethodName(className),DEFAULT_LOC, arbInt(100), arbInt(100) );
}

public str generateMethodName(str className){
	methodName = ["get", "set" , "persist" , "has" , "is", "contains" , "open" , "close"];
	return methodName[ arbInt(size(methodName)-1)]+className;
}

public list[Method] methodList(str className){
	return
		for(int n <- [2 .. arbInt(5)]) append generateMethod(className);
}

public str generatClassName(){
	className = ["Person", "Order" , "Computer" , "Database" , "Connection" , "Beer" , "Fries"];
	return className[ arbInt(size(className)-1) ];
}

public list[Class] classList(){
	return
		for(int n <- [3 .. arbInt(5)]) append generateClass();
}

public Class generateClassWithInnerClass(){
	className = generatClassName();
	return class(className,DEFAULT_LOC, arbInt(100)+400, methodList(className));
}

public Class generateClass(){
	className = generatClassName();
	return class(className,DEFAULT_LOC, arbInt(100)+400, methodList(className));
}

public str generatVisualisationTreeName(){
	VisualisationTreeName = ["persistance", "database" , "util" , "domain" , "common" , "services" , "adapters"];
	return VisualisationTreeName[ arbInt(size(VisualisationTreeName)-1) ];
}

public VisualisationTree generateVisualisationTree(){
	return package(generatVisualisationTreeName() , [], classList() + generateClassWithInnerClass());
}

public list[VisualisationTree] generateVisualisationTreeList(){
	return
		for(int n <- [1 .. arbInt(3)]) append generateVisualisationTree();
}